﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using Relations.DBUtility.SqlServer;
using System.Windows.Forms;
using System.Runtime.Serialization.Json;
using System.IO;
using System.Drawing;
using AlarmManagePlatform.Model;
using AlarmManagePlatform.Model.DB;
using System.Windows.Controls;

namespace AlarmManagePlatform.Static
{
    public static class Methods
    {
        public static void IniSQLDB()
        {
            Static.ParaInfo.SqlDb = new Relations.DBUtility.SqlServer.SqlDb();
            ParaInfo.SqlDb.ConnStr = GetSqlConntion();
        }

        public static string GetSqlConntion()
        {
            //SqlConnectionStringBuilder sqlConnectionStringBuilder = new SqlConnectionStringBuilder()
            //{
            //    DataSource = "192.168.1.233",
            //    UserID = "sa",
            //    Password = "123456",
            //    InitialCatalog = "LMPAlarm",
            //    IntegratedSecurity = false
            //};
            //return sqlConnectionStringBuilder.ToString();

            return Static.ParaInfo.SqlConnectionStringBuilder.ToString();

        }

        internal static SqlDb OpenDataBase()
        {
            Relations.DBUtility.SqlServer.SqlDb _SqlDb = new SqlDb();
            _SqlDb.ConnStr = GetSqlConntion();
            try
            {
                _SqlDb.OpenDb();
                return _SqlDb;
            }
            catch (Exception ex)
            {
                throw new Exception("打开数据库失败，错误信息：" + ex.ToString());
            }
        }

        internal static void CloseDataBase(SqlDb sqlDb)
        {
            try
            {
                sqlDb.CloseDb(sqlDb.DBConn);
                sqlDb = null;
            }
            catch (Exception ex)
            {
                throw new Exception("关闭数据库失败，错误信息：" + ex.ToString());
            }
        }

        internal static void CreateDGVColumns(ref DevComponents.DotNetBar.Controls.DataGridViewX DataGridView, Model.SystemEnum.DGVType type)
        {

            DataGridView.DataSource = null;
            //1、禁止自动创建列
            DataGridView.AutoGenerateColumns = false;
            //2、禁止用户添加、删除行
            DataGridView.AllowUserToAddRows = false;
            DataGridView.AllowUserToDeleteRows = false;
            //3、禁止用户修改行、列大小
            DataGridView.AllowUserToResizeRows = false;
            DataGridView.AllowUserToResizeColumns = false;
            DataGridView.AllowUserToOrderColumns = false;
            //4、隐藏行、列标题列
            DataGridView.RowHeadersVisible = false;
            //DataGridView.ColumnHeadersVisible = false;
            //5、是否可以选择多行
            DataGridView.MultiSelect = false;
            //6、选择的模式：整行、单元格
            DataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            //7、设置标题列和单元格的内容显示格式（居中）
            DataGridView.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            DataGridView.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
            //8、设置单元格是否是只读的
            DataGridView.ReadOnly = false;

            DataGridView.ScrollBars = ScrollBars.Both;

            DataGridView.Rows.Clear();
            DataGridView.Columns.Clear();

            DataGridViewTextBoxColumn _DgvTextBoxColumn;
            DevComponents.DotNetBar.Controls.DataGridViewCheckBoxXColumn _DgvCheckBoxColumn;
            System.Windows.Forms.DataGridViewImageColumn _DgvDeleteColumn;

            _DgvCheckBoxColumn = new DevComponents.DotNetBar.Controls.DataGridViewCheckBoxXColumn();
            _DgvCheckBoxColumn.Name = "Selected";
            _DgvCheckBoxColumn.HeaderText = "选择";
            _DgvCheckBoxColumn.Width = 50;
            _DgvCheckBoxColumn.ReadOnly = false;
            _DgvCheckBoxColumn.DataPropertyName = _DgvCheckBoxColumn.Name;
            DataGridView.Columns.Add(_DgvCheckBoxColumn);

            switch (type)
            {
                case Model.SystemEnum.DGVType.AlarmDetailType:

                    #region 报警器详细信息


                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "InstrumentId";
                    _DgvTextBoxColumn.HeaderText = "仪器索引";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.Visible = false;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "InstrumentName";
                    _DgvTextBoxColumn.HeaderText = "仪器名称";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "FactoryNumber";
                    _DgvTextBoxColumn.HeaderText = "出厂编号";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Model";
                    _DgvTextBoxColumn.HeaderText = "型号";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "ContractNo";
                    _DgvTextBoxColumn.HeaderText = "合同号";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "SubmitUnit";
                    _DgvTextBoxColumn.HeaderText = "送检单位";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Manufacturer";
                    _DgvTextBoxColumn.HeaderText = "制造商";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "sGasTypeList";
                    _DgvTextBoxColumn.HeaderText = "气体类型";
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    _DgvTextBoxColumn.Width = 150;
                    _DgvTextBoxColumn.ReadOnly = true;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "sSampingMode";
                    _DgvTextBoxColumn.HeaderText = "采样方式";
                    _DgvTextBoxColumn.Width = 80;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "ImageInfo";
                    _DgvTextBoxColumn.HeaderText = "形象图片路径";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.Visible = false;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "InputUserName";
                    _DgvTextBoxColumn.HeaderText = "录入人员";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "GPSDesc";
                    _DgvTextBoxColumn.HeaderText = "GPS描述";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Latitude";
                    _DgvTextBoxColumn.HeaderText = "经度";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Longitude";
                    _DgvTextBoxColumn.HeaderText = "纬度";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "ModifyDate";
                    _DgvTextBoxColumn.HeaderText = "修改日期";
                    _DgvTextBoxColumn.Width = 150;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.Visible = false;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "CreateDate";
                    _DgvTextBoxColumn.HeaderText = "创建日期";
                    _DgvTextBoxColumn.Width = 150;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    #endregion 报警器详细信息

                    break;
                case Model.SystemEnum.DGVType.AlarmSimpleType:

                    #region 报警器简略信息

                    _DgvDeleteColumn = new System.Windows.Forms.DataGridViewImageColumn();
                    _DgvDeleteColumn.HeaderText = "";
                    _DgvDeleteColumn.Image = global::AlarmManagePlatform.Properties.Resources.delete;
                    _DgvDeleteColumn.Name = "Delete";
                    _DgvDeleteColumn.ReadOnly = true;
                    _DgvDeleteColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
                    _DgvDeleteColumn.DataPropertyName = _DgvDeleteColumn.Name;
                    _DgvDeleteColumn.Width = 30;
                    DataGridView.Columns.Add(_DgvDeleteColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "InstrumentId";
                    _DgvTextBoxColumn.HeaderText = "仪器索引";
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.Visible = false;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "InstrumentName";
                    _DgvTextBoxColumn.HeaderText = "仪器名称";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "FactoryNumber";
                    _DgvTextBoxColumn.HeaderText = "出厂编号";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Model";
                    _DgvTextBoxColumn.HeaderText = "型号";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "SubmitUnit";
                    _DgvTextBoxColumn.HeaderText = "送检单位";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "sGasTypeList";
                    _DgvTextBoxColumn.HeaderText = "气体类型";
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    _DgvTextBoxColumn.Width = 150;
                    _DgvTextBoxColumn.ReadOnly = true;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "sSampingMode";
                    _DgvTextBoxColumn.HeaderText = "采样方式";
                    _DgvTextBoxColumn.Width = 80;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    #endregion 报警器简略信息

                    break;
                case Model.SystemEnum.DGVType.AlarmSSType:

                    #region 报警器简略信息

                    _DgvDeleteColumn = new System.Windows.Forms.DataGridViewImageColumn();
                    _DgvDeleteColumn.HeaderText = "";
                    _DgvDeleteColumn.Image = global::AlarmManagePlatform.Properties.Resources.delete;
                    _DgvDeleteColumn.Name = "Delete";
                    _DgvDeleteColumn.ReadOnly = true;
                    _DgvDeleteColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True;
                    _DgvDeleteColumn.DataPropertyName = _DgvDeleteColumn.Name;
                    _DgvDeleteColumn.Width = 30;
                    DataGridView.Columns.Add(_DgvDeleteColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "InstrumentId";
                    _DgvTextBoxColumn.HeaderText = "仪器索引";
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.Visible = false;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "InstrumentName";
                    _DgvTextBoxColumn.HeaderText = "仪器名称";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "FactoryNumber";
                    _DgvTextBoxColumn.HeaderText = "出厂编号";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "SubmitUnit";
                    _DgvTextBoxColumn.HeaderText = "送检单位";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "sGasTypeList";
                    _DgvTextBoxColumn.HeaderText = "气体类型";
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    _DgvTextBoxColumn.Width = 150;
                    _DgvTextBoxColumn.ReadOnly = true;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "sSampingMode";
                    _DgvTextBoxColumn.HeaderText = "采样方式";
                    _DgvTextBoxColumn.Width = 80;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    #endregion 报警器简略信息

                    break;
                case Model.SystemEnum.DGVType.TaskInfo:

                    #region 任务信息

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Id";
                    _DgvTextBoxColumn.HeaderText = "任务编号";
                    _DgvTextBoxColumn.Width = 150;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Title";
                    _DgvTextBoxColumn.HeaderText = "标题";
                    _DgvTextBoxColumn.Width = 120;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Desc";
                    _DgvTextBoxColumn.HeaderText = "描述";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "sUserName";
                    _DgvTextBoxColumn.HeaderText = "检测人员";
                    _DgvTextBoxColumn.Width = 80;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Status";
                    _DgvTextBoxColumn.HeaderText = "状态";
                    _DgvTextBoxColumn.Width = 80;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.Visible = false;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "sStatus";
                    _DgvTextBoxColumn.HeaderText = "状态";
                    _DgvTextBoxColumn.Width = 80;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "CreateTime";
                    _DgvTextBoxColumn.HeaderText = "创建日期";
                    _DgvTextBoxColumn.Width = 150;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    #endregion 任务信息

                    break;

                case Model.SystemEnum.DGVType.CheckedInstrumentDetail:

                    #region 检测数据详细

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "ParaName";
                    _DgvTextBoxColumn.HeaderText = "参数名称";
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    _DgvTextBoxColumn.Width = 100;
                    _DgvTextBoxColumn.ReadOnly = true;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);
                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "ParaValue";
                    _DgvTextBoxColumn.HeaderText = "参数值";
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    _DgvTextBoxColumn.Width = 100;
                    _DgvTextBoxColumn.ReadOnly = true;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);
                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "CreateDate";
                    _DgvTextBoxColumn.HeaderText = "日期";
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    _DgvTextBoxColumn.Width = 150;
                    _DgvTextBoxColumn.ReadOnly = true;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    #endregion 检测数据详细

                    break;
                case Model.SystemEnum.DGVType.SubmitUnit:

                    #region 送检单位

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Id";
                    _DgvTextBoxColumn.HeaderText = "编号";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.Visible = false;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Name";
                    _DgvTextBoxColumn.HeaderText = "单位名称";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "ImageInfo";
                    _DgvTextBoxColumn.HeaderText = "图片路径";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.Visible = false;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "GPSDesc";
                    _DgvTextBoxColumn.HeaderText = "GPS描述";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Latitude";
                    _DgvTextBoxColumn.HeaderText = "经度";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Longitude";
                    _DgvTextBoxColumn.HeaderText = "纬度";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "uploadDate";
                    _DgvTextBoxColumn.HeaderText = "更新日期";
                    _DgvTextBoxColumn.Width = 150;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    #endregion 送检单位

                    break;

                case Model.SystemEnum.DGVType.ReportStatisticsInfo:

                    #region 报表信息

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "FactoryNumber";
                    _DgvTextBoxColumn.HeaderText = "出厂编号";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Model";
                    _DgvTextBoxColumn.HeaderText = "型号";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "VerificationOperator";
                    _DgvTextBoxColumn.HeaderText = "检测人员";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "CheckedTime";
                    _DgvTextBoxColumn.HeaderText = "检测日期";
                    _DgvTextBoxColumn.Width = 150;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    #endregion 报表信息

                    break;

                case Model.SystemEnum.DGVType.UserInfo:

                    #region 用户信息

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "userId";
                    _DgvTextBoxColumn.HeaderText = "用户Id";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.Visible = false;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "userName";
                    _DgvTextBoxColumn.HeaderText = "账户";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "passWord";
                    _DgvTextBoxColumn.HeaderText = "密码";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.Visible = false;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "roleId";
                    _DgvTextBoxColumn.HeaderText = "角色索引";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.Visible = false;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "roleName";
                    _DgvTextBoxColumn.HeaderText = "角色类型";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "createTime";
                    _DgvTextBoxColumn.HeaderText = "创建日期";
                    _DgvTextBoxColumn.Width = 150;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    #endregion 用户信息

                    break;

                case Model.SystemEnum.DGVType.CollectTerminal:

                    #region 采集终端信息

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Id";
                    _DgvTextBoxColumn.HeaderText = "Id";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.Visible = false;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "Name";
                    _DgvTextBoxColumn.HeaderText = "名称";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.Visible = false;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "IMEI";
                    _DgvTextBoxColumn.HeaderText = "IMEI";
                    _DgvTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    //_DgvTextBoxColumn.Width = 230;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    _DgvTextBoxColumn = new DataGridViewTextBoxColumn();
                    _DgvTextBoxColumn.Name = "CreateTime";
                    _DgvTextBoxColumn.HeaderText = "创建日期";
                    _DgvTextBoxColumn.Width = 150;
                    _DgvTextBoxColumn.ReadOnly = true;
                    _DgvTextBoxColumn.DataPropertyName = _DgvTextBoxColumn.Name;
                    DataGridView.Columns.Add(_DgvTextBoxColumn);

                    #endregion 采集终端信息

                    break;
            }

            for (int i = 0; i < DataGridView.Columns.Count; i++)
            {
                DataGridView.Columns[i].SortMode = DataGridViewColumnSortMode.NotSortable;
            }

            DataGridView.Refresh();
        }

        public static void InitConfig()
        {
            try
            {
                Relations.Common.IniMng _IniMng = GetIniMng();
                Static.ParaInfo.TaskCumulativeNumber = _IniMng.ReadIntValue("Config", "TaskNumber", 0, 255);
                Static.ParaInfo.LastOpenTime = DateTime.ParseExact(_IniMng.ReadStringValue("Config", "LastOpenTime", DateTime.Now.ToString(Static.ParaInfo.DateFormatShort), 255), Static.ParaInfo.DateFormatShort, System.Globalization.CultureInfo.CurrentCulture);

                ParaInfo.SqlConnectionStringBuilder = new SqlConnectionStringBuilder();
                ParaInfo.SqlConnectionStringBuilder.DataSource = _IniMng.ReadStringValue("SqlConnectionStringBuilder", "DataSource", "192.168.1.233", 255);
                ParaInfo.SqlConnectionStringBuilder.UserID = _IniMng.ReadStringValue("SqlConnectionStringBuilder", "UserID", "sa", 255);
                ParaInfo.SqlConnectionStringBuilder.Password = _IniMng.ReadStringValue("SqlConnectionStringBuilder", "Password", "123456", 255);
                ParaInfo.SqlConnectionStringBuilder.InitialCatalog = _IniMng.ReadStringValue("SqlConnectionStringBuilder", "InitialCatalog", "LMPAlarm", 255);

                if (Static.ParaInfo.LastOpenTime.Year < DateTime.Now.Year)
                {
                    Static.ParaInfo.TaskCumulativeNumber = 0;
                }




                Static.ParaInfo.ParaInfoALL = new DataAccess.tb_ParaInfo().getAll();
                List<Model.DB.tb_DictInfo> gasNameIdList = new DataAccess.tb_DictInfo().getForDictType("GasInfo");
                Model.DB.tb_DictInfo gasName;
                ParaInfo.paraInfo = new Model.ParaInfo();
                gasName = gasNameIdList.Find(value => value.DictCode.Equals("CH4"));
                if (gasName != null)
                {
                    if (Relations.Common.Methods.IsInt(gasName.DictValue))
                        ParaInfo.paraInfo.CH4Id = int.Parse(gasName.DictValue);
                    else
                        ParaInfo.paraInfo.CH4Id = 50;
                }
                else
                    ParaInfo.paraInfo.CH4Id = 50;

                gasName = gasNameIdList.Find(value => value.DictCode.Equals("H2S"));
                if (gasName != null)
                {
                    if (Relations.Common.Methods.IsInt(gasName.DictValue))
                        ParaInfo.paraInfo.H2SId = int.Parse(gasName.DictValue);
                    else
                        ParaInfo.paraInfo.H2SId = 47;
                }
                else
                    ParaInfo.paraInfo.H2SId = 47;

                gasName = gasNameIdList.Find(value => value.DictCode.Equals("O2"));
                if (gasName != null)
                {
                    if (Relations.Common.Methods.IsInt(gasName.DictValue))
                        ParaInfo.paraInfo.O2Id = int.Parse(gasName.DictValue);
                    else
                        ParaInfo.paraInfo.O2Id = 41;
                }
                else
                    ParaInfo.paraInfo.O2Id = 41;

                gasName = gasNameIdList.Find(value => value.DictCode.Equals("CO"));
                if (gasName != null)
                {
                    if (Relations.Common.Methods.IsInt(gasName.DictValue))
                        ParaInfo.paraInfo.COId = int.Parse(gasName.DictValue);
                    else
                        ParaInfo.paraInfo.COId = 49;
                }
                else
                    ParaInfo.paraInfo.COId = 49;


                ParaInfo.paraInfo.TestItemsId = 33;
                ParaInfo.paraInfo.ResultId = 38;
                ParaInfo.paraInfo.AverageId = 39;

                Static.ParaInfo.InstrumentParaInfoList = new List<RelationsLMP.Model.InstrumentParaInfo>()
                {
                     //TestItemsId
                     new RelationsLMP.Model.InstrumentParaInfo() { ParaId = ParaInfo.paraInfo.TestItemsId,Description = "检测项目"},
                     //ResultId
                     new RelationsLMP.Model.InstrumentParaInfo() { ParaId = ParaInfo.paraInfo.ResultId,Description = "结果"},
                    //AverageId
                    new RelationsLMP.Model.InstrumentParaInfo() { ParaId = ParaInfo.paraInfo.AverageId,Description = "平均值"}
                };

                Static.ParaInfo.GasList = new List<Model.DB.tb_ParaInfo>()
                {
                    new Model.DB.tb_ParaInfo(){Id = ParaInfo.paraInfo.O2Id,Code = "O2",Desc ="O2" },
                    new Model.DB.tb_ParaInfo(){Id =ParaInfo. paraInfo.H2SId,Code = "H2S",Desc ="H2S" },
                    new Model.DB.tb_ParaInfo(){Id = ParaInfo.paraInfo.COId,Code = "CO",Desc ="CO" },
                    new Model.DB.tb_ParaInfo(){Id =ParaInfo. paraInfo.CH4Id,Code = "CH4",Desc ="CH4" },
                };

                RelationsLMP.Common.StaticInfo.S_F_ParaInfoAll = new List<RelationsLMP.Model.DB.S_F_ParaInfo>();
                foreach (Model.DB.tb_ParaInfo paraInfo in Static.ParaInfo.ParaInfoALL)
                {
                    RelationsLMP.Common.StaticInfo.S_F_ParaInfoAll.Add(new RelationsLMP.Model.DB.S_F_ParaInfo() {Alias = "",Code = paraInfo.Code,ConversionFactor = paraInfo.ConversionFactor,Description = paraInfo.Desc
                    ,Id = paraInfo.Id,Prec = paraInfo.Prec,RangeMax = paraInfo.RangeMax,RangeMin = paraInfo.RangeMin,Unit = paraInfo.Unit});
                }                

                Static.ParaInfo.webServiceURL = _IniMng.ReadStringValue("WebService", "URL", "http://218.28.140.69:10888/RelationsLMPWebService.asmx", 255);
                if (!File.Exists(RelationsLMP.Common.StaticInfo.GasVerificationProcessSimplifiedFilePath))
                {
                    RelationsLMP.Common.Methods.InitSimplifiedProcess();
                    RelationsLMP.Common.Methods.SaveSimplifiedProcessInfo(RelationsLMP.Common.StaticInfo.GasVerificationProcessSimplifiedInfo, RelationsLMP.Common.StaticInfo.GasVerificationProcessSimplifiedFilePath);
                }
                else
                    RelationsLMP.Common.StaticInfo.GasVerificationProcessSimplifiedInfo = RelationsLMP.Common.Methods.LoadSimplifiedProcessInfo(RelationsLMP.Common.StaticInfo.GasVerificationProcessSimplifiedFilePath);
            }
            catch (Exception ex)
            {
                throw new Exception("初始化配置信息失败，错误信息：" + ex.Message);
            }
        }

        internal static bool webServiceCheckResultIsRight(string resultJson, out string errorInfo)
        {
            bool result;
            string code, keyWord1 = "\"code\":\"", keyWord2 = "\",", keyWord3 = "\"errorMsg\":\"", keyWord4 = "\"}";
            int index1, index2;
            errorInfo = string.Empty;
            index1 = resultJson.IndexOf(keyWord1, 0);
            if (index1 >= 0)
            {
                index2 = resultJson.IndexOf(keyWord2, index1 + keyWord1.Length);
                if (index2 > index1)
                {
                    code = resultJson.Substring(index1 + keyWord1.Length, index2 - index1 - keyWord1.Length);
                    if (code.Equals("00000"))
                        result = true;
                    else
                    {
                        index1 = resultJson.IndexOf(keyWord3, index2);
                        if (index1 >= 0)
                        {
                            index2 = resultJson.IndexOf(keyWord4, index1 + keyWord4.Length);
                            if (index2 > index1)
                                errorInfo = resultJson.Substring(index1 + keyWord3.Length, index2 - index1 - keyWord3.Length);
                        }
                        result = false;
                    }
                }
                else
                    result = false;
            }
            else
                result = false;


            return result;
        }

        public static void SaveConfig()
        {
            Relations.Common.IniMng _IniMng = GetIniMng();
            _IniMng.WriteValue("Config", "TaskNumber", Static.ParaInfo.TaskCumulativeNumber.ToString());
            _IniMng.WriteValue("Config", "LastOpenTime", DateTime.Now.ToString(Static.ParaInfo.DateFormatShort));

            _IniMng.WriteValue("SqlConnectionStringBuilder", "DataSource", ParaInfo.SqlConnectionStringBuilder.DataSource);
            _IniMng.WriteValue("SqlConnectionStringBuilder", "UserID", ParaInfo.SqlConnectionStringBuilder.UserID);
            _IniMng.WriteValue("SqlConnectionStringBuilder", "Password", ParaInfo.SqlConnectionStringBuilder.Password);
            _IniMng.WriteValue("SqlConnectionStringBuilder", "InitialCatalog", ParaInfo.SqlConnectionStringBuilder.InitialCatalog);
        }

        private static Relations.Common.IniMng GetIniMng()
        {
            return new Relations.Common.IniMng(Static.ParaInfo.ConfigFilePath);
        }

        /// <summary>
        /// 拼接字符 （''）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        /// <returns></returns>
        public static string CombiningStrings1<T>(List<T> list)
        {
            string _Result = string.Empty;

            for (int i = 0; i < list.Count; i++)
            {
                _Result += $"'{list[i].ToString()}' , ";
            }
            _Result = _Result.Substring(0, _Result.Length - 2);

            return _Result;
        }

        /// <summary>
        /// 拼接字符 （）
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="list"></param>
        /// <returns></returns>
        public static string CombiningStrings2<T>(List<T> list)
        {
            string _Result = string.Empty;

            for (int i = 0; i < list.Count; i++)
            {
                _Result += $"{list[i].ToString()}, ";
            }
            _Result = _Result.Substring(0, _Result.Length - 2);

            return _Result;
        }

        public static T JOSNConvert<T>(string josn)
        {
            using (var ms = new MemoryStream(Encoding.Unicode.GetBytes(josn)))
            {
                DataContractJsonSerializer deseralizer = new DataContractJsonSerializer(typeof(T));
                T model = (T)deseralizer.ReadObject(ms);// //反序列化ReadObject
                return model;
            }
        }

        public static void UpdateImage(Model.SystemEnum.ImageType type, string id, string imageString)
        {
            //{"type ":1,"id":"1","Image":""}

            string _ErrorInfo = string.Empty;
            string[] _Params = new string[2];
            _Params[0] = Static.ParaInfo.CurrentUser.tonken;
            _Params[1] = "{\"type\":" + (int)type + ",\"id\":\"" + id + "\",\"Image\":\"" + imageString + "\"}";

            object result = Relations.Common.WebServiceHelper.InvokeWebService(Static.ParaInfo.webServiceURL, "updateImagePicture", _Params);

            if (Static.Methods.webServiceCheckResultIsRight(result.ToString(), out _ErrorInfo))
            {

            }
            else
            {
                MessageBox.Show($"上传【{Relations.Common.Methods.GetEnumDescription(type)}】图片失败，错误信息：" + _ErrorInfo, "异常信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }

        public static Bitmap GetImage(Model.SystemEnum.ImageType type, string id)
        {
            //{"type ":1,"id":"1"}
            Bitmap _BitMap;
            string _ErrorInfo = string.Empty;
            string[] _Params = new string[2];
            _Params[0] = Static.ParaInfo.CurrentUser.tonken;
            _Params[1] = "{\"type\":" + (int)type + ",\"id\":\"" + id + "\"}";

            object _Result = Relations.Common.WebServiceHelper.InvokeWebService(Static.ParaInfo.webServiceURL, "getImagePicture", _Params);

            Model.JSON.JSONImagePicture _JSONImagePicture = Methods.JOSNConvert<Model.JSON.JSONImagePicture>(_Result.ToString());
            if (_JSONImagePicture.code == "00000")
            {
                if (!string.IsNullOrEmpty(_JSONImagePicture.result.Image))
                    _BitMap = Relations.Common.Methods.Base64StringToImage(_JSONImagePicture.result.Image);
                else
                    _BitMap = null;
            }
            else
            {
                _BitMap = null;
                //MessageBox.Show($"获取【{Relations.Common.Methods.GetEnumDescription(type)}】图片失败，错误信息：" + _JSONImagePicture.errorMsg, "异常信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return _BitMap;
        }

        public static void InitComBox(ref System.Windows.Forms.ComboBox comBoxTemp, Model.SystemEnum.ComBoxType type)
        {
            comBoxTemp.DataSource = null;
            switch (type)
            {
                case Model.SystemEnum.ComBoxType.GasType:

                    comBoxTemp.DropDownStyle = ComboBoxStyle.DropDownList;
                    comBoxTemp.DisplayMember = "Desc";
                    comBoxTemp.ValueMember = "Id";
                    comBoxTemp.DataSource = ParaInfo.GasList;

                    break;

                case Model.SystemEnum.ComBoxType.SubmitUnit:

                    comBoxTemp.DropDownStyle = ComboBoxStyle.DropDownList;
                    comBoxTemp.DisplayMember = "Name";
                    comBoxTemp.ValueMember = "Id";

                    List<Model.DB.tb_SubmitUnit> _List = new List<Model.DB.tb_SubmitUnit>();
                    _List = new DataAccess.tb_SubmitUnit().GetSubmitUnitList();
                    comBoxTemp.DataSource = _List;

                    break;

                case Model.SystemEnum.ComBoxType.UserInfo:

                    comBoxTemp.DropDownStyle = ComboBoxStyle.DropDownList;
                    comBoxTemp.DisplayMember = "userName";
                    comBoxTemp.ValueMember = "userId";

                    List<Model.DB.tb_User> _UserList = new List<Model.DB.tb_User>();
                    _UserList = new DataAccess.tb_User().getAll().ToList();
                    comBoxTemp.DataSource = _UserList;

                    break;

                case Model.SystemEnum.ComBoxType.SampleModel:

                    comBoxTemp.DropDownStyle = ComboBoxStyle.DropDownList;
                    comBoxTemp.DisplayMember = "Title";
                    comBoxTemp.ValueMember = "Item";
                    comBoxTemp.DataSource = RelationsLMP.Model.SystemEnum.EnumAlertorSampingModeToList();

                    break;

                case SystemEnum.ComBoxType.Role:

                    comBoxTemp.DropDownStyle = ComboBoxStyle.DropDownList;
                    comBoxTemp.DisplayMember = "Name";
                    comBoxTemp.ValueMember = "RoleId";
                    comBoxTemp.DataSource = new DataAccess.tb_RoleInfo().GetRoleInfoList();

                    break;
            }


            if (comBoxTemp.Items.Count > 0)
                comBoxTemp.SelectedIndex = 0;
        }

        public static void CreateReport(Model.DB.tb_AlarminstrumentInfo alarminstrumentInfo, Model.HisCreateTimeInfo hisCreateTimeInfo)
        {

            string _Numbering = DateTime.Now.ToString("yyyyMMdd_HHmmssfff");

            List<Model.HisCreateTimeInfo> ListHisCreateTimeInfo;
            RelationsLMP.Model.ReportFileInfo _ResultInfo = new RelationsLMP.Model.ReportFileInfo();
            //报告编号
            _ResultInfo.ReportNo = _Numbering;
            _ResultInfo.FactoryNumber = alarminstrumentInfo.FactoryNumber;
            _ResultInfo.jyrq = hisCreateTimeInfo.CreateTime;
            _ResultInfo.jyry = Static.ParaInfo.CurrentUser.userName;
            _ResultInfo.sfhg = "\\";
            _ResultInfo.bhgyy = "\\";
            _ResultInfo.jdjl = "\\";

            #region 获取基础信息数据
            int _AboutIndex, _TempListIndex, _FirstIndex;
            List<Model.VerificationItemInfoMation> _ListVerificationItemInfo;
            List<Model.CheckDataInfo> _CheckDataInfoList_About;

            ListHisCreateTimeInfo = new List<Model.HisCreateTimeInfo>();

            //通过气体列表中的气体ID与设备ID，拿到气体信息与创建时间
            foreach (var item in alarminstrumentInfo.GasInfoList)
            {
                ListHisCreateTimeInfo.Add(new HisCreateTimeInfo()
                {
                    ParaInfo = item,
                    CreateTime = new DataAccess.tb_AlarminstrumentHisDeailData().GetHisCreateTime(alarminstrumentInfo.InstrumentId, item.Id)
                });
            }

            //循环获取气体信息的测试数据
            for (int n = 0; n < ListHisCreateTimeInfo.Count; n++)
            {
                if (string.IsNullOrEmpty(ListHisCreateTimeInfo[n].CreateTime))
                {
                    continue;
                }

                //通过设备ID、创建时间，获取His信息
                _CheckDataInfoList_About = new DataAccess.tb_AlarminstrumentHisData().GetCheckDataInfo(alarminstrumentInfo.InstrumentId, ListHisCreateTimeInfo[n].CreateTime, ParaInfo.InstrumentParaInfoList);

                if (_CheckDataInfoList_About.Count <= 0)
                    continue;
                //throw new Exception("未找到被检测仪器的历史数据！");

                //判定所有检定项目是否存在于His列表中
                _ListVerificationItemInfo = null;
                foreach (SystemEnum.VerificationItem item in Enum.GetValues(typeof(SystemEnum.VerificationItem)))
                {
                    if (_ListVerificationItemInfo == null)
                        _ListVerificationItemInfo = new List<VerificationItemInfoMation>();
                    _FirstIndex = _CheckDataInfoList_About.FindIndex(value => (value.tb_ParaInfo.Id.Equals(ParaInfo.paraInfo.TestItemsId) && value.Verificationitemid.Equals(item)));

                    if (_FirstIndex < 0)
                        continue;

                    _ListVerificationItemInfo.Add(new VerificationItemInfoMation()
                    {
                        VerificationItem = item,
                        FirstIndex = _FirstIndex
                    });
                }

                //判定是否同一信息（项目、结果、平均值）
                _AboutIndex = -1;
                //确定List的Index
                _TempListIndex = -1;

                //循环气体检定项目（示值误差、重复性、响应时间、声报警、光报警）
                for (int i = 0; i < _ListVerificationItemInfo.Count; i++)
                {
                    if (_ListVerificationItemInfo[i].FirstIndex < 0)
                        continue;

                    //重新开始时 进行ListIndex初始化
                    _TempListIndex = -1;

                    //遍历His列表
                    foreach (CheckDataInfo item in _CheckDataInfoList_About)
                    {
                        //不同于当前气体检定项目 跳过
                        if (!item.Verificationitemid.Equals(_ListVerificationItemInfo[i].VerificationItem))
                            continue;

                        //当参数信息ID==检测项目对应ID时，即为下一次（检定项目、结果、平均值）的开始
                        if (item.tb_ParaInfo.Id.Equals(ParaInfo.paraInfo.TestItemsId))
                        {
                            //初始化同一信息初始值
                            _AboutIndex = item.IndexId;
                            //ListIndex默认+1
                            _TempListIndex++;
                            //开辟新空间存储历史信息
                            _ListVerificationItemInfo[i].ListHisInfoMation.Add(new HisInfoMation());
                        }

                        //确认同一信息
                        if (_AboutIndex == item.IndexId)
                        {
                            if (item.tb_ParaInfo.Id.Equals(ParaInfo.paraInfo.TestItemsId))
                            {
                                //检定项目
                                _ListVerificationItemInfo[i].ListHisInfoMation[_TempListIndex].TestItems = item.ParaValue;

                                //测试值
                                _ListVerificationItemInfo[i].ListHisInfoMation[_TempListIndex].TestValue = item.TestValue;

                                //加载详细信息列表
                                _ListVerificationItemInfo[i].ListHisInfoMation[_TempListIndex].ListCheckDataInfo = new DataAccess.tb_AlarminstrumentHisDeailData().GetCheckDataInfo(alarminstrumentInfo.InstrumentId, item.IndexId, item.CreateDate);
                            }
                            if (item.tb_ParaInfo.Id.Equals(ParaInfo.paraInfo.ResultId))
                            {
                                //结果
                                _ListVerificationItemInfo[i].ListHisInfoMation[_TempListIndex].Result = item.ParaValue;
                            }
                            if (item.tb_ParaInfo.Id.Equals(ParaInfo.paraInfo.AverageId))
                            {
                                //平均值
                                _ListVerificationItemInfo[i].ListHisInfoMation[_TempListIndex].Average = item.ParaValue;
                            }
                        }
                    }
                }
                //将信息附加到对应气体列表中
                ListHisCreateTimeInfo[n].ListVerificationItem = _ListVerificationItemInfo;
            }

            #endregion 获取基础信息数据

            List<string> _ListReplace = null;
            string _FileName = string.Empty;
            string _TemplateName = string.Empty;

            _ListReplace = new List<string>();

            AddBasisInfo(alarminstrumentInfo, _ListReplace, _Numbering);
            _FileName = alarminstrumentInfo.FactoryNumber + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xls";

            switch (ListHisCreateTimeInfo.Count)
            {
                case 1:

                    if (ListHisCreateTimeInfo[0].ParaInfo.Id == ParaInfo.paraInfo.CH4Id)
                    {
                        _TemplateName = "\\Template_CH4.xls";
                    }
                    else if (ListHisCreateTimeInfo[0].ParaInfo.Id == ParaInfo.paraInfo.O2Id)
                    {
                        _TemplateName = "\\Template_O2.xls";
                    }
                    else if (ListHisCreateTimeInfo[0].ParaInfo.Id == ParaInfo.paraInfo.COId)
                    {
                        _TemplateName = "\\Template_CO.xls";
                    }
                    else if (ListHisCreateTimeInfo[0].ParaInfo.Id == ParaInfo.paraInfo.H2SId)
                    {
                        _TemplateName = "\\Template_H2S.xls";
                    }

                    SingleGasIs(alarminstrumentInfo, ListHisCreateTimeInfo, _ListReplace, ListHisCreateTimeInfo[0].ParaInfo.Id);

                    break;
                case 2:
                    #region CH4+O2

                    SingleGasIs(alarminstrumentInfo, ListHisCreateTimeInfo, _ListReplace, ParaInfo.paraInfo.CH4Id);

                    SingleGasIs(alarminstrumentInfo, ListHisCreateTimeInfo, _ListReplace, ParaInfo.paraInfo.O2Id);

                    #endregion CH4+O2
                    _TemplateName = "\\Template_CH4+O2.xls";

                    break;
                case 4:
                    #region AllGas

                    SingleGasIs(alarminstrumentInfo, ListHisCreateTimeInfo, _ListReplace, ParaInfo.paraInfo.CH4Id);

                    SingleGasIs(alarminstrumentInfo, ListHisCreateTimeInfo, _ListReplace, ParaInfo.paraInfo.O2Id);

                    SingleGasIs(alarminstrumentInfo, ListHisCreateTimeInfo, _ListReplace, ParaInfo.paraInfo.COId);

                    SingleGasIs(alarminstrumentInfo, ListHisCreateTimeInfo, _ListReplace, ParaInfo.paraInfo.H2SId);

                    #endregion AllGas
                    _TemplateName = "\\Template_All.xls";
                    break;

                default:
                    foreach (var item in ListHisCreateTimeInfo)
                    {
                        _TemplateName += " " + item.ParaInfo.Code;
                    }
                    //System.Windows.Forms.MessageBox.Show(_ListHisCreateTimeInfo.Count + _TemplateName);
                    throw new Exception("气体参数信息有误【" + _TemplateName + "】");
            }


            _ResultInfo.sfhg = AllGasWholeChek(ListHisCreateTimeInfo);
            _ListReplace.Add(string.Format("[{0}]|{1}", "检定结论-结果", _ResultInfo.sfhg));

            //替换Excel
            ReplaceExcelContent(_FileName, _TemplateName, _ListReplace, false);
            _ResultInfo.FileName = _FileName;
            //return _ResultInfo;
        }

        /// <summary>
        /// 添加基础信息
        /// </summary>
        /// <param name="alarminstrumentInfo"></param>
        /// <param name="list"></param>
        /// <param name="numbering"></param>
        private static void AddBasisInfo(tb_AlarminstrumentInfo alarminstrumentInfo, List<string> list, string numbering)
        {
            list.Add(string.Format("[{0}]|{1}", "证书编号", numbering));
            list.Add(string.Format("[{0}]|{1}", "检定日期", DateTime.Now.ToString("yyyy/MM/dd")));
            list.Add(string.Format("[{0}]|{1}", "温度", "28"));
            list.Add(string.Format("[{0}]|{1}", "湿度", "28"));
            list.Add(string.Format("[{0}]|{1}", "制造厂", alarminstrumentInfo.Manufacturer));
            list.Add(string.Format("[{0}]|{1}", "型号", alarminstrumentInfo.Model));
            list.Add(string.Format("[{0}]|{1}", "出厂编号", alarminstrumentInfo.FactoryNumber));
            //list.Add(string.Format("[{0}]|{1}", "量程", checkedInstrument.Range));
            list.Add(string.Format("[{0}]|{1}", "送检单位", alarminstrumentInfo.SubmitUnit));
            list.Add(string.Format("[{0}]|{1}", "采样方式", Relations.Common.Methods.GetEnumDescription(alarminstrumentInfo.SampingMode)));
        }

        /// <summary>
        /// 单气体是否存在
        /// </summary>
        /// <param name="CheckedInstrument"></param>
        /// <param name="ListHisCreateTimeInfo"></param>
        /// <param name="_ListReplace"></param>
        /// <param name="ParaIdInfo"></param>
        private static void SingleGasIs(tb_AlarminstrumentInfo alarminstrumentInfo, List<HisCreateTimeInfo> ListHisCreateTimeInfo, List<string> _ListReplace, int GasId)
        {
            try
            {
                int _Index = ListHisCreateTimeInfo.FindIndex(value => value.ParaInfo.Id.Equals(GasId));
                if (_Index >= 0)
                {
                    CreatePrintDataSingle(ListHisCreateTimeInfo[_Index], _ListReplace);
                    NewCompareResults(ListHisCreateTimeInfo[_Index], alarminstrumentInfo.SampingMode, _ListReplace);
                }
                else
                {
                    CreatePrintDataSingle(new HisCreateTimeInfo()
                    {
                        ParaInfo = new DataAccess.tb_ParaInfo().GetParaInfo(GasId.ToString()),
                        ListVerificationItem = new List<VerificationItemInfoMation>()
                    }, _ListReplace);

                    //NewCompareResults(new HisCreateTimeInfo()
                    //{
                    //    ParaInfo = new DataAccess.tb_ParaInfo().GetParaInfo(GasId.ToString()),
                    //    ListVerificationItem = new List<VerificationItemInfoMation>()
                    //}, alarminstrumentInfo.SampingMode, _ListReplace);
                }
                Model.DB.tb_ParaInfo paraInfo = new DataAccess.tb_ParaInfo().GetParaInfo(GasId.ToString());
                _ListReplace.Add(string.Format("[{0}]|{1}", paraInfo.Code.ToUpper() + "量程", paraInfo == null ? "" : (paraInfo.RangeMin.ToString() + "~" + paraInfo.RangeMax.ToString())) + "(" + paraInfo.Unit + ")");
            }
            catch (Exception ex)
            {

            }
            finally
            {
                string s1= string.Empty;
            }
        }

        #region 创建导出数据

        /// <summary>
        /// 创建导出数据——单个气体
        /// </summary>
        /// <param name="hisCreateTimeInfo"></param>
        /// <param name="listReplace"></param>
        private static void CreatePrintDataSingle(HisCreateTimeInfo hisCreateTimeInfo, List<string> listReplace)
        {
            string _AudibleAlarmResult = string.Empty;
            try
            {
                //示值误差
                AddIndicationErrorOrResponseTime(hisCreateTimeInfo, listReplace, Model.SystemEnum.VerificationItem.IndicationError, hisCreateTimeInfo.ParaInfo.Code + "-示值误差");

                //重复性
                AddRepeatability(hisCreateTimeInfo, listReplace, hisCreateTimeInfo.ParaInfo.Code);

                //响应时间
                AddIndicationErrorOrResponseTime(hisCreateTimeInfo, listReplace, Model.SystemEnum.VerificationItem.ResponseTime, hisCreateTimeInfo.ParaInfo.Code + "-响应时间");

                //报警误差！！！ 只针对H2S
                if (hisCreateTimeInfo.ParaInfo.Id == ParaInfo.paraInfo.H2SId)
                {
                    AddAlarmError(hisCreateTimeInfo, listReplace, Model.SystemEnum.VerificationItem.AlarmError, hisCreateTimeInfo.ParaInfo.Code + "-" + Relations.Common.Methods.GetEnumDescription(Model.SystemEnum.VerificationItem.AlarmError));
                }

                ////(string.Format("[{0}]|{1}", "声光报警", "/"));
                if (hisCreateTimeInfo.ParaInfo.Id == ParaInfo.paraInfo.CH4Id)
                {
                    _AudibleAlarmResult = GetAudibleAlarm(hisCreateTimeInfo);

                    if (_AudibleAlarmResult.IndexOf("异常") >= 0)
                    {
                        listReplace.Add((string.Format("[{0}]|{1}", "CH4-声光报警", _AudibleAlarmResult)));
                        listReplace.Add((string.Format("[{0}]|{1}", "CH4-声光报警-检定结果", "不合格")));
                    }
                    else if (_AudibleAlarmResult.IndexOf("正常") >= 0)
                    {
                        listReplace.Add((string.Format("[{0}]|{1}", "CH4-声光报警", _AudibleAlarmResult)));
                        listReplace.Add((string.Format("[{0}]|{1}", "CH4-声光报警-检定结果", "合格")));
                    }
                    else
                    {
                        listReplace.Add((string.Format("[{0}]|{1}", "CH4-声光报警", "/")));
                        listReplace.Add((string.Format("[{0}]|{1}", "CH4-声光报警-检定结果", "/")));
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("生成打印数据失败，错误信息：" + ex.Message);
            }
        }

        /// <summary>
        /// 添加示值误差或响应时间新
        /// </summary>
        /// <param name="hisCreateTimeInfo"></param>
        /// <param name="list"></param>
        /// <param name="verificationItem"></param>
        /// <param name="description"></param>
        internal static void AddIndicationErrorOrResponseTime(HisCreateTimeInfo hisCreateTimeInfo, List<string> list, Model.SystemEnum.VerificationItem verificationItem, string description)
        {
            int _Index = -1;
            //绝对误差
            //平均值-标气浓度
            float _AbsoluteError, _AbsMaxAbsoluteError = 0.0F;
            //相对误差
            //绝对误差/标气浓度*100%
            float _RelativeError, _AbsMaxRelativeError = 0.0F;
            bool? _COIndicationErrorCheck = true;
            bool _IsCOIndicationError;

            if (hisCreateTimeInfo.ParaInfo.Id == ParaInfo.paraInfo.COId && verificationItem.Equals(SystemEnum.VerificationItem.IndicationError))
            {
                _IsCOIndicationError = true;
            }
            else
            {
                _IsCOIndicationError = false;
            }

            _Index = hisCreateTimeInfo.ListVerificationItem.FindIndex(x => x.VerificationItem.Equals(verificationItem));

            if (_Index < 0)
            {
                hisCreateTimeInfo.ListVerificationItem.Add(new VerificationItemInfoMation()
                {
                    VerificationItem = verificationItem,
                    VerificationItemIsQualified = null
                });

                _Index = hisCreateTimeInfo.ListVerificationItem.FindIndex(x => x.VerificationItem.Equals(verificationItem));
            }


            for (int i = 0; i < hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation.Count; i++)
            {
                list.Add(string.Format("[{0}]|{1}", description + "-" + (i + 1) + "-项目", hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[i].TestValue));
                list.Add(string.Format("[{0}]|{1}", description + "-" + (i + 1) + "-平均", hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[i].Average));
                list.Add(string.Format("[{0}]|{1}", description + "-" + (i + 1) + "-结果", hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[i].Result));

                if (_IsCOIndicationError)
                {
                    _AbsoluteError = float.Parse(hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[i].Average) - hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[i].TestValue;

                    if (Math.Abs(_AbsoluteError) >= Math.Abs(_AbsMaxAbsoluteError))
                    {
                        _AbsMaxAbsoluteError = _AbsoluteError;
                    }

                    _RelativeError = _AbsoluteError / hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[i].TestValue * 100;

                    if (Math.Abs(_RelativeError) >= Math.Abs(_AbsMaxRelativeError))
                    {
                        _AbsMaxRelativeError = _RelativeError;
                    }

                    list.Add(string.Format("[{0}]|{1}", description + "-" + (i + 1) + "-绝对误差", _AbsoluteError.ToString("F2")));
                    list.Add(string.Format("[{0}]|{1}", description + "-" + (i + 1) + "-相对误差", _RelativeError.ToString("F2")));

                }

                AddVerificationInfoMation(list, verificationItem, description, i + 1, hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[i].ListCheckDataInfo);
            }

            if (_IsCOIndicationError)
            {
                if (Math.Abs(_AbsMaxAbsoluteError) > 5 && Math.Abs(_AbsMaxRelativeError) > 10)
                {
                    _COIndicationErrorCheck = false;
                }
            }

            if (hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation.Count < 3)
            {
                list.Add(string.Format("[{0}]|{1}", description + "-3-项目", "/"));
                list.Add(string.Format("[{0}]|{1}", description + "-3-平均", "/"));
                list.Add(string.Format("[{0}]|{1}", description + "-3-结果", "/"));

                if (_IsCOIndicationError)
                {
                    list.Add(string.Format("[{0}]|{1}", description + "-3-绝对误差", "/"));
                    list.Add(string.Format("[{0}]|{1}", description + "-3-相对误差", "/"));
                }

                AddVerificationInfoMation(list, verificationItem, description, 3);
            }
            if (hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation.Count < 2)
            {
                list.Add(string.Format("[{0}]|{1}", description + "-2-项目", "/"));
                list.Add(string.Format("[{0}]|{1}", description + "-2-平均", "/"));
                list.Add(string.Format("[{0}]|{1}", description + "-2-结果", "/"));

                if (_IsCOIndicationError)
                {
                    list.Add(string.Format("[{0}]|{1}", description + "-2-绝对误差", "/"));
                    list.Add(string.Format("[{0}]|{1}", description + "-2-相对误差", "/"));
                }

                AddVerificationInfoMation(list, verificationItem, description, 2);
            }
            if (hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation.Count < 1)
            {
                list.Add(string.Format("[{0}]|{1}", description + "-1-项目", "/"));
                list.Add(string.Format("[{0}]|{1}", description + "-1-平均", "/"));
                list.Add(string.Format("[{0}]|{1}", description + "-1-结果", "/"));

                if (_IsCOIndicationError)
                {
                    list.Add(string.Format("[{0}]|{1}", description + "-1-绝对误差", "/"));
                    list.Add(string.Format("[{0}]|{1}", description + "-1-相对误差", "/"));
                    _COIndicationErrorCheck = null;
                }

                AddVerificationInfoMation(list, verificationItem, description, 1);
            }

            if (_IsCOIndicationError)
            {
                if (_COIndicationErrorCheck == null)
                {
                    list.Add(string.Format("[{0}]|{1}", description + "-绝对误差绝对值最大值", "/"));
                    list.Add(string.Format("[{0}]|{1}", description + "-相对误差绝对值最大值", "/"));
                }
                else
                {
                    list.Add(string.Format("[{0}]|{1}", description + "-绝对误差绝对值最大值", _AbsMaxAbsoluteError.ToString("F2")));
                    list.Add(string.Format("[{0}]|{1}", description + "-相对误差绝对值最大值", _AbsMaxRelativeError.ToString("F2")));
                }

                hisCreateTimeInfo.ListVerificationItem[_Index].VerificationItemIsQualified = _COIndicationErrorCheck;
            }
        }

        /// <summary>
        /// 添加重复性
        /// </summary>
        /// <param name="hisCreateTimeInfo"></param>
        /// <param name="list"></param>
        /// <param name="gasName"></param>
        internal static void AddRepeatability(HisCreateTimeInfo hisCreateTimeInfo, List<string> list, string gasName)
        {
            int _Index = -1;
            _Index = hisCreateTimeInfo.ListVerificationItem.FindIndex(x => x.VerificationItem.Equals(Model.SystemEnum.VerificationItem.Repeatability));
            if (_Index >= 0)
            {
                if (hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation.Count > 0)
                {
                    if (hisCreateTimeInfo.ParaInfo.Id == ParaInfo.paraInfo.CH4Id)
                        list.Add(string.Format("[{0}]|{1}", gasName + "-重复性-项目", hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[0].TestValue / 5F));
                    else
                        list.Add(string.Format("[{0}]|{1}", gasName + "-重复性-项目", hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[0].TestValue));
                    list.Add(string.Format("[{0}]|{1}", gasName + "-重复性-平均", hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[0].Average));
                    list.Add(string.Format("[{0}]|{1}", gasName + "-重复性-结果", hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[0].Result));

                    for (int i = 0; i < hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[0].ListCheckDataInfo.Count; i++)
                    {
                        list.Add(string.Format("[{0}]|{1}", gasName + "-重复性-" + (i + 1), hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[0].ListCheckDataInfo[i].ParaValue));
                    }

                    if (GetTestMax(Model.SystemEnum.VerificationItem.Repeatability) > hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[0].ListCheckDataInfo.Count)
                    {
                        for (int i = hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[0].ListCheckDataInfo.Count; i < GetTestMax(Model.SystemEnum.VerificationItem.Repeatability); i++)
                        {
                            list.Add(string.Format("[{0}]|{1}", gasName + "-重复性-" + (i + 1), "/"));
                        }
                    }
                }
            }
            else
            {
                list.Add(string.Format("[{0}]|{1}", gasName + "-重复性-项目", "/"));
                list.Add(string.Format("[{0}]|{1}", gasName + "-重复性-平均", "/"));
                list.Add(string.Format("[{0}]|{1}", gasName + "-重复性-结果", "/"));

                for (int i = 0; i < GetTestMax(Model.SystemEnum.VerificationItem.Repeatability); i++)
                {
                    list.Add(string.Format("[{0}]|{1}", gasName + "-重复性-" + (i + 1), "/"));
                }
            }
        }

        /// <summary>
        /// 添加报警值--只针对H2S
        /// </summary>
        /// <param name="hisCreateTimeInfo"></param>
        /// <param name="list"></param>
        /// <param name="verificationItem"></param>
        /// <param name="description"></param>
        internal static void AddAlarmError(HisCreateTimeInfo hisCreateTimeInfo, List<string> list, Model.SystemEnum.VerificationItem verificationItem, string description)
        {
            int _Index = -1;

            _Index = hisCreateTimeInfo.ListVerificationItem.FindIndex(x => x.VerificationItem.Equals(verificationItem));

            if (_Index < 0)
            {
                hisCreateTimeInfo.ListVerificationItem.Add(new VerificationItemInfoMation()
                {
                    VerificationItem = verificationItem,
                    VerificationItemIsQualified = null
                });

                _Index = hisCreateTimeInfo.ListVerificationItem.FindIndex(x => x.VerificationItem.Equals(verificationItem));
            }

            int _GasVerificationProcessInfoIndex;

            //是否存在该检定项目
            bool _IsVerificationItem = false;

            if (hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation.Count > 0)
            {
                //该状态下为简化版
                _GasVerificationProcessInfoIndex = RelationsLMP.Common.StaticInfo.GasVerificationProcessSimplifiedInfo.FindIndex(value => value.GasName.Id == ParaInfo.paraInfo.H2SId);
                if (_GasVerificationProcessInfoIndex >= 0)
                {
                    _IsVerificationItem = true;
                    list.Add($"[{description + "-设定报警点"}]|{RelationsLMP.Common.StaticInfo.GasVerificationProcessSimplifiedInfo[_GasVerificationProcessInfoIndex].AlarmErrorInfo.AlarmSetValue}");
                    list.Add($"[{description + "-报警设置误差"}]|{RelationsLMP.Common.StaticInfo.GasVerificationProcessSimplifiedInfo[_GasVerificationProcessInfoIndex].AlarmErrorInfo.DetectionError}");
                    list.Add($"[{description + "-测量次数"}]|{ GetTestMax(Model.SystemEnum.VerificationItem.AlarmError)}");
                }
            }
            if (!_IsVerificationItem)
            {
                list.Add($"[{description + "-设定报警点"}]|/");
                list.Add($"[{description + "-报警设置误差"}]|/");
                list.Add($"[{description + "-测量次数"}]|/");
            }

            for (int i = 0; i < hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation.Count; i++)
            {
                list.Add(string.Format("[{0}]|{1}", description + "-" + (i + 1) + "-项目", hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[i].TestValue));
                list.Add(string.Format("[{0}]|{1}", description + "-" + (i + 1) + "-平均", hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[i].Average));
                list.Add(string.Format("[{0}]|{1}", description + "-" + (i + 1) + "-结果", hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[i].Result));

                list.Add(string.Format("[{0}]|{1}", description + "-" + (i + 1) + "-最大值",
                    hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[0].ListCheckDataInfo.Max(value => float.Parse(value.ParaValue))));

                AddVerificationInfoMation(list, verificationItem, description, i + 1, hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation[i].ListCheckDataInfo);
            }

            if (hisCreateTimeInfo.ListVerificationItem[_Index].ListHisInfoMation.Count < 1)
            {
                list.Add(string.Format("[{0}]|{1}", description + "-1-项目", "/"));
                list.Add(string.Format("[{0}]|{1}", description + "-1-平均", "/"));
                list.Add(string.Format("[{0}]|{1}", description + "-1-结果", "/"));

                list.Add(string.Format("[{0}]|{1}", description + "-1-最大值", "/"));

                AddVerificationInfoMation(list, verificationItem, description, 1);
            }
        }

        /// <summary>
        /// 获取声光报警结果
        /// </summary>
        /// <param name="hisCreateTimeInfo"></param>
        /// <returns></returns>
        internal static string GetAudibleAlarm(HisCreateTimeInfo hisCreateTimeInfo)
        {
            string _Result = string.Empty;
            string _SoundAlarm = string.Empty;
            string _LightAlarm = string.Empty;
            int _SoundAlarmIndex = -1;
            int _LightAlarmIndex = -1;

            //声报警
            _SoundAlarmIndex = hisCreateTimeInfo.ListVerificationItem.FindIndex(x => x.VerificationItem.Equals(Model.SystemEnum.VerificationItem.SoundAlarm));
            if (_SoundAlarmIndex >= 0)
            {
                _SoundAlarm = hisCreateTimeInfo.ListVerificationItem[_SoundAlarmIndex].ListHisInfoMation[0].Result;
            }
            else
                _SoundAlarmIndex = 0;

            switch (_SoundAlarm)
            {
                case "正常":
                    hisCreateTimeInfo.ListVerificationItem[_SoundAlarmIndex].VerificationItemIsQualified = true;
                    break;

                case "异常":
                    hisCreateTimeInfo.ListVerificationItem[_SoundAlarmIndex].VerificationItemIsQualified = false;
                    break;

                case "":
                    hisCreateTimeInfo.ListVerificationItem[_SoundAlarmIndex].VerificationItemIsQualified = null;
                    break;
            }

            //光报警
            _LightAlarmIndex = hisCreateTimeInfo.ListVerificationItem.FindIndex(x => x.VerificationItem.Equals(Model.SystemEnum.VerificationItem.LightAlarm));
            if (_LightAlarmIndex >= 0)
            {
                _LightAlarm = hisCreateTimeInfo.ListVerificationItem[_LightAlarmIndex].ListHisInfoMation[0].Result;
            }
            else
                _LightAlarmIndex = 0;

            switch (_LightAlarm)
            {
                case "正常":
                    hisCreateTimeInfo.ListVerificationItem[_LightAlarmIndex].VerificationItemIsQualified = true;
                    break;

                case "异常":
                    hisCreateTimeInfo.ListVerificationItem[_LightAlarmIndex].VerificationItemIsQualified = false;
                    break;

                case "":
                    hisCreateTimeInfo.ListVerificationItem[_LightAlarmIndex].VerificationItemIsQualified = null;
                    break;
            }

            #region 判定结果
            if (!string.IsNullOrEmpty(_SoundAlarm) || !string.IsNullOrEmpty(_LightAlarm))
            {
                switch (hisCreateTimeInfo.ListVerificationItem[_SoundAlarmIndex].VerificationItemIsQualified)
                {
                    case true:
                        switch (hisCreateTimeInfo.ListVerificationItem[_LightAlarmIndex].VerificationItemIsQualified)
                        {
                            case true:
                                _Result = "声光报警正常";
                                break;

                            case false:
                                _Result = "声报警正常 光报警异常";
                                break;

                            case null:
                                _Result = "声报警正常";
                                break;
                        }
                        break;

                    case false:
                        switch (hisCreateTimeInfo.ListVerificationItem[_LightAlarmIndex].VerificationItemIsQualified)
                        {
                            case true:
                                _Result = "声报警异常 光报警正常";
                                break;

                            case false:
                                _Result = "声光报警异常";
                                break;

                            case null:
                                _Result = "声报警异常";
                                break;
                        }
                        break;

                    case null:
                        switch (hisCreateTimeInfo.ListVerificationItem[_LightAlarmIndex].VerificationItemIsQualified)
                        {
                            case true:
                                _Result = "光报警正常";
                                break;

                            case false:
                                _Result = "光报警异常";
                                break;

                            case null:
                                _Result = "/";
                                break;
                        }
                        break;
                }
            }
            else
            {
                _Result = "/";
            }
            #endregion 判定结果
            return _Result;
        }


        /// <summary>
        /// 添加详细信息 "/"
        /// </summary>
        /// <param name="list"></param>
        /// <param name="verificationItem"></param>
        /// <param name="description"></param>
        /// <param name="index"></param>
        internal static void AddVerificationInfoMation(List<string> list, Model.SystemEnum.VerificationItem verificationItem, string description, int index)
        {
            int _Max = GetTestMax(verificationItem);

            for (int n = 0; n < _Max; n++)
            {
                list.Add(string.Format("[{0}]|{1}", description + "-" + index + "-" + (n + 1), "/"));
            }
        }

        /// <summary>
        /// 添加详细信息 Value
        /// </summary>
        /// <param name="list"></param>
        /// <param name="verificationItem"></param>
        /// <param name="description"></param>
        /// <param name="index"></param>
        /// <param name="listInfo"></param>
        internal static void AddVerificationInfoMation(List<string> list, Model.SystemEnum.VerificationItem verificationItem, string description, int index, List<CheckDataInfo> listInfo)
        {
            int _Max = GetTestMax(verificationItem);

            for (int n = 0; n < listInfo.Count; n++)
            {
                list.Add(string.Format("[{0}]|{1}", description + "-" + index + "-" + (n + 1), listInfo[n].ParaValue));
            }

            if (_Max <= listInfo.Count)
                return;

            for (int n = listInfo.Count; n < _Max; n++)
            {
                list.Add(string.Format("[{0}]|{1}", description + "-" + index + "-" + (n + 1), "/"));
            }
        }


        #endregion 创建导出数据

        /// <summary>
        /// 比较结果
        /// </summary>
        /// <param name="hisCreateTimeInfo"></param>
        /// <param name="alertorSampingMode"></param>
        /// <param name="list"></param>
        internal static void NewCompareResults(HisCreateTimeInfo hisCreateTimeInfo, RelationsLMP.Model.SystemEnum.AlertorSampingMode alertorSampingMode, List<string> list)
        {
            int _Index = -1;
            double _ComparisonValue = 0;
            List<double> _Values = new List<double>();
            List<RelationsLMP.Model.ObjectInfo> _ListChecked = new List<RelationsLMP.Model.ObjectInfo>();

            foreach (SystemEnum.VerificationItem verificationItem in Enum.GetValues(typeof(SystemEnum.VerificationItem)))
            {
                switch (verificationItem)
                {
                    case SystemEnum.VerificationItem.IndicationError:
                    case SystemEnum.VerificationItem.Repeatability:
                    case SystemEnum.VerificationItem.ResponseTime:
                    case SystemEnum.VerificationItem.AlarmError:

                        _Index = hisCreateTimeInfo.ListVerificationItem.FindIndex(x => x.VerificationItem.Equals(verificationItem));

                        if (_Index < 0)
                        {
                            hisCreateTimeInfo.ListVerificationItem.Add(new VerificationItemInfoMation()
                            {
                                VerificationItem = verificationItem,
                                VerificationItemIsQualified = null
                            });
                            break;
                        }

                        //switch (RelationsLMP.Common.StaticInfo.ConfigInfo.ProcessType)
                        //{
                        //    case SystemEnum.ProcessType.Simplified:
                        //        _ComparisonValue = SimplifiedGetComparisonValue(verificationItem, alertorSampingMode, hisCreateTimeInfo.ParaInfo.Id);
                        //        break;

                        //    case SystemEnum.ProcessType.Standard:
                        //        _ComparisonValue = CustomGetComparisonValue(verificationItem, alertorSampingMode, hisCreateTimeInfo.ParaInfo.Id);
                        //        break;
                        //}
                        _ComparisonValue = SimplifiedGetComparisonValue(verificationItem, alertorSampingMode, hisCreateTimeInfo.ParaInfo.Id);

                        if (!verificationItem.Equals(SystemEnum.VerificationItem.IndicationError) || hisCreateTimeInfo.ParaInfo.Id != ParaInfo.paraInfo.COId)
                        {
                            //设置比较值时，自动比较结果
                            hisCreateTimeInfo.ListVerificationItem[_Index].ComparisonValue = _ComparisonValue;
                        }

                        break;

                    default:
                        break;
                }

            }

            NewSingleGasWholeCheck(hisCreateTimeInfo);

            AddVerificationItemResult(hisCreateTimeInfo, list, alertorSampingMode);
            AddSingleGasWholeResult(hisCreateTimeInfo, list);
        }

        /// <summary>
        /// 检查多组气体检定项目是否合格
        /// </summary>
        /// <param name="listHisCreateTimeInfo"></param>
        /// <returns></returns>
        internal static string AllGasWholeChek(List<HisCreateTimeInfo> listHisCreateTimeInfo)
        {
            bool? _IsQualified;

            if (listHisCreateTimeInfo.Find(value => value.GasIsQualified.Equals(false)) != null)
            {
                //不合格
                _IsQualified = false;
            }
            else if (listHisCreateTimeInfo.Find(value => value.GasIsQualified.Equals(true)) != null)
            {
                //合格
                _IsQualified = true;
            }
            else
            {
                _IsQualified = null;
                //为空
            }
            return GetResult(_IsQualified);
        }

        /// <summary>
        /// 检查单个气体检定项目是否合格
        /// </summary>
        /// <param name="hisCreateTimeInfo"></param>
        private static void NewSingleGasWholeCheck(HisCreateTimeInfo hisCreateTimeInfo)
        {
            if (hisCreateTimeInfo.ListVerificationItem.Find(value => value.VerificationItemIsQualified.Equals(false)) != null)
            {
                hisCreateTimeInfo.GasIsQualified = false;
            }
            else if (hisCreateTimeInfo.ListVerificationItem.Find(value => value.VerificationItemIsQualified.Equals(true)) != null)
            {
                hisCreateTimeInfo.GasIsQualified = true;
            }
            else
            {
                hisCreateTimeInfo.GasIsQualified = null;
            }
        }

        /// <summary>
        /// 添加单个检定项目结果
        /// </summary>
        /// <param name="hisCreateTimeInfo"></param>
        /// <param name="list"></param>
        /// <param name="alertorSampingMode"></param>
        private static void AddVerificationItemResult(HisCreateTimeInfo hisCreateTimeInfo, List<string> list, RelationsLMP.Model.SystemEnum.AlertorSampingMode alertorSampingMode)
        {
            string _Result = string.Empty;
            foreach (VerificationItemInfoMation item in hisCreateTimeInfo.ListVerificationItem)
            {
                if (item.VerificationItem.Equals(SystemEnum.VerificationItem.LightAlarm) ||
                    item.VerificationItem.Equals(SystemEnum.VerificationItem.SoundAlarm))
                {
                    continue;
                }

                _Result = GetResult(item.VerificationItemIsQualified);

                list.Add(string.Format("[{0}]|{1}", hisCreateTimeInfo.ParaInfo.Code + "-" + Relations.Common.Methods.GetEnumDescription(item.VerificationItem) + "-检定结果", _Result));

                if (item.VerificationItem.Equals(SystemEnum.VerificationItem.ResponseTime))
                {
                    switch (alertorSampingMode)
                    {
                        case RelationsLMP.Model.SystemEnum.AlertorSampingMode.Diffussion:

                            list.Add(string.Format("[{0}]|{1}", hisCreateTimeInfo.ParaInfo.Code + "-" + Relations.Common.Methods.GetEnumDescription(item.VerificationItem) + "-" + Relations.Common.Methods.GetEnumDescription(RelationsLMP.Model.SystemEnum.AlertorSampingMode.Diffussion) + "-绝对值最大值", _Result.Equals("/") ? "/" : item.AbsMaxValue.ToString()));

                            list.Add(string.Format("[{0}]|{1}", hisCreateTimeInfo.ParaInfo.Code + "-" + Relations.Common.Methods.GetEnumDescription(item.VerificationItem) + "-" + Relations.Common.Methods.GetEnumDescription(RelationsLMP.Model.SystemEnum.AlertorSampingMode.PumpSuction) + "-绝对值最大值", "/"));

                            break;
                        case RelationsLMP.Model.SystemEnum.AlertorSampingMode.PumpSuction:

                            list.Add(string.Format("[{0}]|{1}", hisCreateTimeInfo.ParaInfo.Code + "-" + Relations.Common.Methods.GetEnumDescription(item.VerificationItem) + "-" + Relations.Common.Methods.GetEnumDescription(RelationsLMP.Model.SystemEnum.AlertorSampingMode.Diffussion) + "-绝对值最大值", "/"));

                            list.Add(string.Format("[{0}]|{1}", hisCreateTimeInfo.ParaInfo.Code + "-" + Relations.Common.Methods.GetEnumDescription(item.VerificationItem) + "-" + Relations.Common.Methods.GetEnumDescription(RelationsLMP.Model.SystemEnum.AlertorSampingMode.PumpSuction) + "-绝对值最大值", _Result.Equals("/") ? "/" : item.AbsMaxValue.ToString()));

                            break;
                    }
                }
                else
                {
                    list.Add(string.Format("[{0}]|{1}", hisCreateTimeInfo.ParaInfo.Code + "-" + Relations.Common.Methods.GetEnumDescription(item.VerificationItem) + "-绝对值最大值", _Result.Equals("/") ? "/" : item.AbsMaxValue.ToString()));
                }
            }

        }

        /// <summary>
        /// 添加单个气体所有检定项目结果
        /// </summary>
        /// <param name="hisCreateTimeInfo"></param>
        /// <param name="list"></param>
        private static void AddSingleGasWholeResult(HisCreateTimeInfo hisCreateTimeInfo, List<string> list)
        {
            //string _Result = string.Empty;
            //_Result = GetResult(hisCreateTimeInfo.GasIsQualified);
            //list.Add(string.Format("[{0}]|{1}", hisCreateTimeInfo.ParaInfo.Code + "-结果", _Result));

            //☑ □
            switch (hisCreateTimeInfo.GasIsQualified)
            {
                case null:
                    list.Add(string.Format("[{0}]|{1}", hisCreateTimeInfo.ParaInfo.Code + "-合格", "□"));
                    list.Add(string.Format("[{0}]|{1}", hisCreateTimeInfo.ParaInfo.Code + "-不合格", "□"));
                    break;
                case true:
                    list.Add(string.Format("[{0}]|{1}", hisCreateTimeInfo.ParaInfo.Code + "-合格", "☑"));
                    list.Add(string.Format("[{0}]|{1}", hisCreateTimeInfo.ParaInfo.Code + "-不合格", "□"));
                    break;
                case false:
                    list.Add(string.Format("[{0}]|{1}", hisCreateTimeInfo.ParaInfo.Code + "-合格", "□"));
                    list.Add(string.Format("[{0}]|{1}", hisCreateTimeInfo.ParaInfo.Code + "-不合格", "☑"));
                    break;
            }
        }

        /// <summary>
        /// 通过bool? 获取结果
        /// </summary>
        /// <param name="isQualified"></param>
        /// <returns></returns>
        private static string GetResult(bool? isQualified)
        {
            string _Result = string.Empty;

            switch (isQualified)
            {
                case null:
                    _Result = "/";
                    break;
                case true:
                    _Result = "合格";
                    break;
                case false:
                    _Result = "不合格";
                    break;
            }

            return _Result;
        }

        private static int GetTestMax(Model.SystemEnum.VerificationItem verificationItem)
        {
            int _Max = -1;
            switch (verificationItem)
            {
                case Model.SystemEnum.VerificationItem.IndicationError:
                    _Max = 3;
                    //_Max = RelationsLMP.Common.StaticInfo.TestMaxCount.IndicationError;
                    break;

                case Model.SystemEnum.VerificationItem.ResponseTime:
                    _Max = 3;
                    //_Max = RelationsLMP.Common.StaticInfo.TestMaxCount.ResponseTime;
                    break;

                case Model.SystemEnum.VerificationItem.Repeatability:
                    _Max = 6;
                    //_Max = RelationsLMP.Common.StaticInfo.TestMaxCount.Repeatability;
                    break;

                case Model.SystemEnum.VerificationItem.AlarmError:
                    _Max = 3;
                    //_Max = RelationsLMP.Common.StaticInfo.TestMaxCount.AlarmError;
                    break;
            }

            return _Max;
        }

        /// <summary>
        /// 获取简化版检定流程比对值
        /// </summary>
        /// <param name="verificationItem">检定项目</param>
        /// <param name="alertorSampingMode">报警器采样方式</param>
        /// <param name="paraInfoId">气体ID</param>
        /// <returns></returns>
        internal static float SimplifiedGetComparisonValue(SystemEnum.VerificationItem verificationItem, RelationsLMP.Model.SystemEnum.AlertorSampingMode alertorSampingMode, int paraInfoId)
        {
            int _GasVerificationProcessInfoIndex;
            float _DetectionError;
            _GasVerificationProcessInfoIndex = RelationsLMP.Common.StaticInfo.GasVerificationProcessSimplifiedInfo.FindIndex(value => value.GasName.Id == paraInfoId);
            if (_GasVerificationProcessInfoIndex < 0)
            {
                return 0F;
            }

            switch (verificationItem)
            {
                case SystemEnum.VerificationItem.IndicationError:
                    _DetectionError = RelationsLMP.Common.StaticInfo.GasVerificationProcessSimplifiedInfo[_GasVerificationProcessInfoIndex].IndicationErrorInfo.DetectionError;
                    break;

                case SystemEnum.VerificationItem.Repeatability:
                    _DetectionError = RelationsLMP.Common.StaticInfo.GasVerificationProcessSimplifiedInfo[_GasVerificationProcessInfoIndex].RepeatabilityInfo.DetectionError;
                    break;

                case SystemEnum.VerificationItem.ResponseTime:
                    //_DetectionError = RelationsLMP.Common.StaticInfo.GasVerificationProcessSimplifiedInfo[_GasVerificationProcessInfoIndex].ResponseTimeInfo.DetectionError;
                    //响应时间固定为  吸入式：30S 扩散式：60S
                    if (alertorSampingMode == RelationsLMP.Model.SystemEnum.AlertorSampingMode.PumpSuction)
                    {
                        _DetectionError = 30F;
                    }
                    else
                    {
                        _DetectionError = 60F;
                    }

                    break;

                case SystemEnum.VerificationItem.AlarmError:
                    _DetectionError = RelationsLMP.Common.StaticInfo.GasVerificationProcessSimplifiedInfo[_GasVerificationProcessInfoIndex].AlarmErrorInfo.DetectionError;
                    break;

                default:
                    _DetectionError = 0F;
                    break;
            }

            return _DetectionError;
        }

        internal static void ReplaceExcelContent(string fileName, string templateName, List<string> replaceInfo, bool isOpenFile)
        {
            #region 复制模板
            //目标路径
            string _TargetFile = ParaInfo.ReportHomePath + fileName;
            //模板路径
            string _ReportTemplate = ParaInfo.ReportTemplateHomePath + templateName;

            if (!File.Exists(_ReportTemplate))
            {
                throw new Exception(string.Format("未找到报告模板【{0}】。", _ReportTemplate));
            }

            if (File.Exists(_TargetFile))
                File.Delete(_TargetFile);
            File.Copy(_ReportTemplate, _TargetFile);
            #endregion 复制模板

            if (replaceInfo.Count <= 0) return;
            Microsoft.Office.Interop.Excel.Application _Excel = new Microsoft.Office.Interop.Excel.ApplicationClass();
            Microsoft.Office.Interop.Excel.Workbook _Workbook = _Excel.Workbooks.Open(_TargetFile
                    , System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value
                    , System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value
                    , System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value
                    , System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value
                    , System.Reflection.Missing.Value, System.Reflection.Missing.Value);
            Microsoft.Office.Interop.Excel.Worksheet CurrWorksheet;
            _Excel.DisplayAlerts = false;
            _Excel.AlertBeforeOverwriting = false;
            try
            {
                string[] _ItemList;
                for (int n = 1; n <= _Workbook.Sheets.Count; n++)
                {
                    CurrWorksheet = (Microsoft.Office.Interop.Excel.Worksheet)_Workbook.Sheets[n];
                    for (int i = 0; i < replaceInfo.Count; i++)
                    {
                        _ItemList = replaceInfo[i].ToString().Split("|".ToCharArray());
                        if (_ItemList.Length < 2) continue;
                        CurrWorksheet.Cells.Replace(_ItemList[0], _ItemList[1], Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
                    }
                }

                _Workbook.Saved = true;
                _Workbook.Save();
                _Workbook.Close();
                _Workbook = null;
            }
            catch (Exception ex)
            {
                throw new Exception("替换Excel内容失败，错误信息：" + ex.Message.ToString());
            }
            finally
            {
                _Excel.Quit();
                _Excel = null;
            }

            if (isOpenFile)
            {
                if (File.Exists(_TargetFile))
                    Relations.Common.Methods.StartFile(_TargetFile);
                else
                    throw new Exception(string.Format("未找到报告文件[{0}]！", _TargetFile));
            }
        }
    }
}
